/*
 * JPanelWizardClaseSimpleFinish.java
 *
 * Created on 11-abr-2012, 21:50:37
 */
package com.ufps.cuatro.vistas.asistente.clase.compleja.constructor;

import java.util.ArrayList;

import javax.swing.event.ListDataListener;

import org.jdesktop.application.Action;

import com.ufps.cuatro.controlador.render.UtilRender;
import com.ufps.cuatro.modelo.analizador.ObjetoReflexion;
import com.ufps.cuatro.modelo.representacion.ObjetoTipoDatoReflexion;
import com.ufps.cuatro.modelo.representacion.UtilRepresentacion;

/**
 *
 * @author Catc
 */
public class JPanelWizardClaseComplejaSelectConstructor extends javax.swing.JPanel {
    private static final long serialVersionUID = 8925725153208109294L;
    
    private ObjetoTipoDatoReflexion objTipoDato;    
    private ArrayList<ObjetoReflexion> objConstructores;    
    private ObjetoReflexion objConstructor;

    /** Creates new form JPanelWizardClaseSimpleFinish */
    public JPanelWizardClaseComplejaSelectConstructor(ObjetoTipoDatoReflexion objTipoDato) {
       try{
        initComponents();
        this.objTipoDato = objTipoDato;        
        this.jLabelClase.setText(objTipoDato.getStrClassPath());        
        objConstructores = UtilRepresentacion.devolverPropiedadesClase(objTipoDato.getObjClass(), UtilRepresentacion.PROPIEDADES_CONSTRUCTORES, false);                
        UtilRender.helperRenderJList(jListDisponibles, objConstructores, 0, javax.swing.ListSelectionModel.SINGLE_SELECTION);        
        if(!objConstructores.isEmpty()){
            jListDisponibles.setSelectedIndex(0);
            objConstructor = (ObjetoReflexion) jListDisponibles.getSelectedValue();
        }
    }catch(java.lang.Exception ex){}
       
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel2 = new javax.swing.JLabel();
        jLabelClase = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jListDisponibles = new javax.swing.JList();

        jLabel2.setText("Clase:");
        jLabel2.setName("jLabel2"); // NOI18N

        jLabelClase.setBackground(new java.awt.Color(255, 255, 255));
        jLabelClase.setText("Información de la Clase");
        jLabelClase.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jLabelClase.setName("jLabelClase"); // NOI18N
        jLabelClase.setOpaque(true);

        jLabel1.setText("Seleccione el Constructor que desea utilizar para la Representación.");
        jLabel1.setName("jLabel1"); // NOI18N

        jLabel4.setBackground(new java.awt.Color(255, 255, 255));
        jLabel4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/ufps/cuatro/resources/icono app x 48.png"))); // NOI18N
        jLabel4.setText("<html><b>Bienvenido al Asistente de Representación de Clases por Constructor.</b><br> <p> Este asistente le permitirá generar Vistas (JPanel)  de Clases por medio de un Constructor con Parámetros.</p></html>");
        jLabel4.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jLabel4.setName("jLabel4"); // NOI18N
        jLabel4.setOpaque(true);

        jLabel6.setText("Constructores Disponibles.");
        jLabel6.setName("jLabel6"); // NOI18N

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        jListDisponibles.setName("jListDisponibles"); // NOI18N
        jListDisponibles.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                jListDisponiblesValueChanged(evt);
            }
        });
        jScrollPane1.setViewportView(jListDisponibles);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 527, Short.MAX_VALUE)
                    .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.LEADING, 0, 0, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabelClase, javax.swing.GroupLayout.DEFAULT_SIZE, 491, Short.MAX_VALUE))
                    .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 527, Short.MAX_VALUE)
                    .addComponent(jLabel6, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 527, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jLabelClase))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel1)
                .addGap(11, 11, 11)
                .addComponent(jLabel6)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 231, Short.MAX_VALUE)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void jListDisponiblesValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_jListDisponiblesValueChanged
        if(jListDisponibles.getSelectedIndex() == -1){            
            return;
        }
        objConstructor = (ObjetoReflexion) jListDisponibles.getSelectedValue();
    }//GEN-LAST:event_jListDisponiblesValueChanged

    @Action
    public void add() {        
    }

    @Action
    public void addAll() {        
    }

    @Action
    public void del() {        
    }

    @Action
    public void delAll() {        
    }

    @Action
    public void help() {
    }

    public ObjetoTipoDatoReflexion getObjTipoDato() {
        return objTipoDato;
    }
    
    public boolean isListEmpty(){
        return this.objConstructores.isEmpty();
    }
    
    public void addListDataListener(ListDataListener i){
        this.jListDisponibles.getModel().addListDataListener(i);
    }

    public ObjetoReflexion getObjConstructor() {
        return objConstructor;
    }

    public ArrayList<ObjetoReflexion> getObjConstructores() {
        return objConstructores;
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabelClase;
    private javax.swing.JList jListDisponibles;
    private javax.swing.JScrollPane jScrollPane1;
    // End of variables declaration//GEN-END:variables
}
